<%@ page contentType="text/html; charset=utf-8" language="java" pageEncoding="utf-8" %>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>开发文档-设备</title>
		<link type="text/css" rel="stylesheet" href="css/pages/xlink/global.css">
		<link type="text/css" rel="stylesheet" href="css/pages/xlink/developer.css">
	</head>
	<body>
		<div id="top">
			<div id="top_logo"><span>Xlink</span></div>
			<div id="top_right">
				<div id="top_right_ul1"> 
				    <ul>
				    	<li><a href="contact.html">联系我们</a></li>
				    	<li><a href="#">工作机会</a></li>
				    	<li><a href="mydevice.html">用户中心</a></li>
				    </ul>
				</div>
				<div id="top_right_ul2">
					<ul>
					<li><a hre="index.html">首页</a></li>
					<li><a hre="developer.html">开发者</a></li>
					<li><a hre="#">搜索</a></li>
					<li><a hre="#">社区</a></li>
					<li><a hre="#">博客</a></li>
					<li><a hre="contact.html">联系我们</a></li>
					</ul>
				</div>
			</div>
		</div>

		<div id="banner" class="short bg2">
			<div class="inset">
				<h1>设备 Devices</h1>
				<p>一个device表示一组传感器的集合.</p>
			</div>
		</div>

		<div id="first">
			<div id="left">
				<h1>导航中心</h1>
				<ul>
					<li><a href="#">快速开始</a></li>
					<li><a href="#">开发例程</a></li>
					<li><a href="#">案例分析</a></li>
					<li><a href="#">移动客户端</a></li>
					<li><a href="#">API文档</a></li>
					<li><a href="#">使用条款</a></li>
				</ul>
			</div>
			<div id="right">
				<div id="developer_main" class="devdoc">
					<h1>API文档 <i>(版本1.0，版本 <a href="#">v1.1</a> 测试中)</i></h1>
					<h2>设备 Devices</h2>
					<p class="info">一个device表示一组传感器的集合.</p>
					<table id="table_device" class="common">
						<thead>
							<tr><th colspan="3">API列表</th></tr>
						</thead>
						<tbody>
											<tr><td><a href="#">/v1.0/devices</a></td><td width="320">创建设备</td><td width="80"><a href="#" target="_blank">在线调试</a></td></tr>
											<tr><td><a href="#">/v1.0/device/&lt;device_id&gt;</a></td><td width="320">编辑设备</td><td width="80"><a href="#" target="_blank">在线调试</a></td></tr>
											<tr><td><a href="#">/v1.0/devices</a></td><td width="320">罗列设备</td><td width="80"><a href="#" target="_blank">在线调试</a></td></tr>
											<tr><td><a href="#">/v1.0/device/&lt;device_id&gt;</a></td><td width="320">查看设备</td><td width="80"><a href="#" target="_blank">在线调试</a></td></tr>
											<tr><td><a href="#">/v1.0/device/&lt;device_id&gt;</a></td><td width="320">删除设备</td><td width="80"><a href="#" target="_blank">在线调试</a></td></tr>
										</tbody>
					</table>
							<h3><a id="anchor_13" class="local" name="anchor_13"></a>创建设备</h3>
					<p>对该URL的一个HTTP POST请求将为您创建一个新的设备.</p>

			<h4>URL</h4>

			<p>http://api.Xlink.net/v1.0/devices</p>


			<h4>数据格式</h4>

			<p>JSON</p>

			<h4>数据格式说明</h4>

			<table class="common">
				<thead>
					<tr>
						<th>参数名</th>
						<th>必需</th>
						<th>类型</th>
						<th>说明</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<th>title</th>
						<td>true</td>
						<td>string</td>
						<td>设备标题</td>
					</tr>
					<tr>
						<th>about</th>
						<td>false</td>
						<td>string</td>
						<td>设备简介</td>
					</tr>
					<tr>
						<th>tags</th>
						<td>false</td>
						<td>array</td>
						<td>标签数组</td>
					</tr>
					<tr>
						<th>tags</th>
						<td>false</td>
						<td>array</td>
						<td>标签数组</td>
					</tr>
					<tr>
						<th>location</th>
						<td>false</td>
						<td>json</td>
						<td>local: string 地点名称，latitude: float 经度, longitude: float 纬度</td>
					</tr>
				</tbody>
			</table>

			<pre>{
			     "title":"test",
			     "about":"test api",
			     "tags":["temperature","lab"],
			     "location":{
			    "local":"Qingdao",
			    "latitude":0.444,
			    "longitude":0.555
			   }
			}</pre>

			<h4>Method</h4>

			<p>POST</p>

			<h4>返回值</h4>

			<p>新设备的ID</p>

			<table class="common">
				<thead>
					<tr>
						<th>参数名</th>
						<th>类型</th>
						<th>说明</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<th>device_id</th>
						<td>int</td>
						<td>设备id</td>
					</tr>
				</tbody>
			</table>

			<pre>{
				"device_id": 2
			}</pre>

			<h4>访问授权</h4>

			<p>需要在HTTP Header中增加API Key来授权写入操作, 具体请参照<a href="#">API Key</a>.</p>

			<h4>请求实例 (运用curl):</h4>

			<div class="tabs">
			<ul>
				<li>CURL</li>
			</ul>

			<ul>
				<li>
				<pre>curl --request POST --data-binary @datafile.txt --header "U-ApiKey: YOUR_API_KEY_HERE" http://api.Xlink.net/v1.0/devices</pre>

				<p><em>Note:</em>只需将要修改的设备信息放到datafile.txt中,需要在HTTP Header中增加API Key来授权写入操作, 具体请参照<a href="#">API Key.</a></p>
				</li>
			</ul>
			</div>
							<h3><a id="anchor_14" class="local" name="anchor_14"></a>编辑设备</h3>
					<p class="info">根据设备ID编辑已经接入的设备</p>
					<h4>URL</h4>
					<p>http://api.Xlink.net/v1.0/device/&lt;device_id&gt;</p>
					<p class="note"><em>Note: </em>对该<code>URL</code>的一个<code>HTTP PUT</code>请求将更新指定设备的信息,其中&lt;device_id&gt;为所要更新的设备的id. 若您的客户端不支持PUT请求, 请使用url方式模拟, 具体参照模拟PUT, DELETE请求.</p>
					<h4>请求参数</h4>
					<table class="common">
						<thead>
							<tr>
								<th>参数名</th>
								<th>必需</th>
								<th>类型</th>
								<th>说明</th>
							</tr>
						</thead>
						<tbody>
							<tr>
								<th>device_id</th>
								<td>true</td>
								<td>string</td>
								<td>设备ID</td>
							</tr>
						</tbody>
					</table>
					<h4>数据格式</h4>
					<p>JSON</p>
					<h4>数据格式说明</h4>
					<table class="common">
						<thead>
							<tr>
								<th width="100">参数名</th>
								<th width="50">必需</th>
								<th width="80">类型</th>
								<th>说明</th>
							</tr>
						</thead>
						<tbody>
							<tr>
								<th>title</th>
								<td>true</td>
								<td>string</td>
								<td>设备标题</td>
							</tr>
							<tr>
								<th>about</th>
								<td>false</td>
								<td>string</td>
								<td>设备简介</td>
							</tr>
							<tr>
								<th>tags</th>
								<td>false</td>
								<td>array</td>
								<td>标签数组</td>
							</tr>
							<tr>
								<th>tags</th>
								<td>false</td>
								<td>array</td>
								<td>标签数组</td>
							</tr>
							<tr>
								<th>location</th>
								<td>false</td>
								<td>json</td>
								<td>local: string 地点名称，latitude: float 经度, longitude: float 纬度</td>
							</tr>
						</tbody>
					</table>
					<pre>{
			    "title":"test",
			    "about":"just a test",
			    "tags":["lab","temperature"],
			    "location":{
			    "local":"Qingdao",
			    "latitude":0.444,
			    "longitude":0.555
				}
			}</pre>
					<h4>Method</h4>
					<p>PUT</p>
					<h4>返回值</h4>
					<p>HTTP Headers only</p>
					<h4>访问授权</h4>
					<p>需要在HTTP Header中增加API Key来授权写入操作, 具体请参照<a href="#">API Key</a>.</p>
					<h4>请求实例 (运用curl):</h4>
					<div class="tabs">
						<ul class="tab">
							<li class="select">CURL</li>
						</ul>
						<ul class="tab_content">
							<li style="display: list-item;">
								<pre>curl --request PUT --data-binary @datafile.txt
				--header "U-ApiKey: YOUR_API_KEY_HERE" http://api.Xlink.net/v1.0/device/12</pre>
								<p class="note"><em>Note:</em>只需将要修改的设备信息放到datafile.txt中,需要在HTTP Header中增加API Key来授权写入操作, 具体请参照<a href="#">API Key.</a></p>
							</li>
						</ul>
					</div>
									<h3><a id="anchor_17" class="local" name="anchor_17"></a>罗列设备</h3>
					<p>对该URL的一个HTTP GET请求将得到所有设备信息的列表.</p>

			<h4>URL</h4>

			<p>http://api.Xlink.net/v1.0/devices</p>

			<h4>请求参数</h4>

			<table class="common">
				<thead>
					<tr>
						<th>参数名</th>
						<th>必需</th>
						<th>类型</th>
						<th>说明</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<th>device_id</th>
						<td>true</td>
						<td>string</td>
						<td>设备ID</td>
					</tr>
				</tbody>
			</table>

			<h4>数据格式</h4>

			<p>JSON</p>

			<h4>数据格式说明</h4>

			<table class="common">
				<thead>
					<tr>
						<th>参数名</th>
						<th>必需</th>
						<th>类型</th>
						<th>说明</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<th>id</th>
						<td>true</td>
						<td>int</td>
						<td>设备ID</td>
					</tr>
					<tr>
						<th>title</th>
						<td>true</td>
						<td>string</td>
						<td>设备标题</td>
					</tr>
					<tr>
						<th>about</th>
						<td>false</td>
						<td>string</td>
						<td>设备简介</td>
					</tr>
				</tbody>
			</table>

			<pre>[
			  {
			    "id": "2",
			    "title": "test2",
			    "about": "just a test"
			  },
			  {
			    "id": "3",
			    "title": "test3",
			    "about": "just a test"
			  }
			]</pre>

			<h4>Method</h4>

			<p>GET</p>

			<h4>返回值</h4>

			<p>用户所有的设备</p>

			<h4>访问授权</h4>

			<p>需要在HTTP Header中增加API Key来授权GET操作, 具体请参照<a href="#">API Key</a>.</p>

			<h4>请求实例 (运用curl):</h4>

			<div class="tabs">
			<ul>
				<li>CURL</li>
			</ul>

			<ul>
				<li>
				<pre>curl --request GET --header "U-ApiKey: YOUR_API_KEY_HERE" http://api.Xlink.net/v1.0/devices</pre>

				<p><em>Note:</em>需要在HTTP Header中增加API Key来授权GET操作, 具体请参照<a href="#">API Key.</a></p>
				</li>
			</ul>
			</div>
							<h3><a id="anchor_18" class="local" name="anchor_18"></a>查看设备</h3>
							<p class="info">对该URL的一个HTTP GET请求将得到所要查看设备的详细内容,其中&lt;device_id&gt;为所要查看的设备的id.</p>
					<h4>URL</h4>
					<p>http://api.Xlink.net/v1.0/device/&lt;device_id&gt;</p>
					<h4>请求参数</h4>
					<table class="common">
						<thead>
							<tr>
								<th>参数名</th>
								<th>必需</th>
								<th>类型</th>
								<th>说明</th>
							</tr>
						</thead>
						<tbody>
							<tr>
								<th>device_id</th>
								<td>true</td>
								<td>string</td>
								<td>设备ID</td>
							</tr>
						</tbody>
					</table>
					<h4>数据格式说明</h4>
					<table class="common">
						<thead>
							<tr>
								<th width="100">参数名</th>
								<th width="50">必需</th>
								<th width="80">类型</th>
								<th>说明</th>
							</tr>
						</thead>
						<tbody>
							<tr>
								<th>title</th>
								<td>true</td>
								<td>string</td>
								<td>设备标题</td>
							</tr>
							<tr>
								<th>about</th>
								<td>false</td>
								<td>string</td>
								<td>设备简介</td>
							</tr>
							<tr>
								<th>tags</th>
								<td>false</td>
								<td>array</td>
								<td>标签数组</td>
							</tr>
							<tr>
								<th>tags</th>
								<td>false</td>
								<td>array</td>
								<td>标签数组</td>
							</tr>
							<tr>
								<th>location</th>
								<td>false</td>
								<td>json</td>
								<td>local: string 地点名称，latitude: float 经度, longitude: float 纬度</td>
							</tr>
						</tbody>
					</table>
					<pre>{
			  "title": "test3",
			  "about": "just a test",
			  "tags": "lab",
			  "local": "Qingdao",
			  "latitude": 0.444,
			  "longitude": 0.555
			}</pre>
					<h4>Method</h4>
					<p>GET</p>
					<h4>返回值</h4>
					<p>请求的设备信息</p>
					<h4>访问授权</h4>
					<p>需要在HTTP Header中增加API Key来授权写入操作, 具体请参照<a href="#">API Key</a>.</p>
					<h4>请求实例 (运用curl):</h4>
					<div class="tabs">
						<ul class="tab">
							<li class="select">CURL</li>
						</ul>
						<ul class="tab_content">
							<li style="display: list-item;">
								<pre>curl --request GET --header "U-ApiKey: YOUR_API_KEY_HERE" http://api.Xlink.net/v1.0/device/12</pre>
								<p class="note"><em>Note:</em>需要在HTTP Header中增加API Key来授权GET操作, 具体请参照<a href="#">API Key.</a></p>
							</li>
						</ul>
					</div>				<h3><a id="anchor_19" class="local" name="anchor_19"></a>删除设备</h3>
					<p class="info">对该URL的一个HTTP DELETE请求将将删除指定的设备,其中&lt;device_id&gt;为所要删除的设备的id.</p>
					<h4>URL</h4>
					<p>http://api.Xlink.net/v1.0/device/&lt;device_id&gt;</p>
					<p class="note"><em>Note: </em>对该<code>URL</code>的一个<code>HTTP PUT</code>请求将更新指定设备的信息,其中&lt;device_id&gt;为所要更新的设备的id. 若您的客户端不支持PUT请求, 请使用url方式模拟, 具体参照模拟PUT, DELETE请求.</p>
					<h4>请求参数</h4>
					<table class="common">
						<thead>
							<tr>
								<th>参数名</th>
								<th>必需</th>
								<th>类型</th>
								<th>说明</th>
							</tr>
						</thead>
						<tbody>
							<tr>
								<th>device_id</th>
								<td>true</td>
								<td>string</td>
								<td>设备ID</td>
							</tr>
						</tbody>
					</table>
					<h4>数据格式</h4>
					<p>JSON</p>
					<h4>Method</h4>
					<p>DELETE</p>
					<h4>返回值</h4>
					<p>HTTP Headers only</p>
					<h4>访问授权</h4>
					<p>需要在HTTP Header中增加API Key来授权写入操作, 具体请参照<a href="#">API Key</a>.</p>
					<h4>请求实例 (运用curl):</h4>
					<div class="tabs">
						<ul class="tab">
							<li class="select">CURL</li>
						</ul>
						<ul class="tab_content">
							<li style="display: list-item;">
								<pre>curl --request DELETE --header "U-ApiKey: YOUR_API_KEY_HERE" http://api.Xlink.net/v1.0/device/12</pre>
								<p class="note"><em>Note:</em>需要在HTTP Header中增加API Key来授权DELETE操作, 具体请参照<a href="#">API Key.</a></p>
							</li>
						</ul>
					</div>					
					<div class="doc_nav" style="display: block;">
						<h4>快速导航</h4>
						<ul>
											<li><a href="#">创建设备</a></li>
											<li><a href="#">编辑设备</a></li>
											<li><a href="#">罗列设备</a></li>
											<li><a href="#">查看设备</a></li>
											<li><a href="#">删除设备</a></li>
										</ul>
						
						<div class="navbar"><a class="gotop">GO TOP</a></div>
					</div>
						</div>
			</div>
		</div>
		<div id="bottom">@Xlink 版权所有</div>
		<script type="text/javascript">
		var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
		document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F5f94f1c230854f8066134ebed007b8c7' type='text/javascript'%3E%3C/script%3E"));
		</script><script src="../../../js/pages/xlink/h.js" type="text/javascript"></script><script src="../../../js/pages/xlink/sea-debug.js" data-config="/resource/js/config" data-main="/resource/js/main"></script>
		<script>X
		seajs.use(['/resource/js/scroller', '/resource/js/devnav', '/resource/js/searchbar', '/resource/js/devdocnav', '/resource/js/tab'], function(scroller, devnav, Searchbar, devDocnav, tab){
			var Scroller = scroller.Scroller;
			var partnersScroller = new Scroller({
				container: '#forums .mask',
				navBars: {
					prev: '#forums .navbar .prev',
					next: '#forums .navbar .next'
				},
				contentWidth: 1440,
				containerWidth: 815,
				stepLength: 150
			});
			
			var creatorScroller = new Scroller({
				container: '#creator .box',
				navBars: {
					prev: '#creator .navbar .prev',
					next: '#creator .navbar .next'
				},
				contentWidth: 860,
				containerWidth: 430,
				stepLength: 430
			});
			
			devnav.init();
			
			new Searchbar({
				
			});
			new Searchbar({
					container: '#header .subnav .searchbar',
					input: '#header .subnav .searchbar input',
					button: '#header .subnav .searchbar button',
					direction: 'down'
			});
			
			devDocnav.init({
				rel: '#table_device'
			})
			
			tab({
				s_container: '.tabs',
				s_tab: '.tab>li',
				s_content: '.tab_content>li'
			});
		});

		</script>
	</body>
</html>
